<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php
	
	function dbconnect() 
	{ 
		require('config.php'); 
		static $connect = null; 
		if ($connect === null) 
			{
				 $connect =  mysql_connect($host, $user, $passwd) or die(mysql_error());
				 mysql_query("SET character_set_results=utf8", $connect);
				 mysql_select_db($database); 
			} 
		return $connect; 
	} 
	
	function insert_nxb($post) 
	{ 
	 
		$query= mysql_query("INSERT INTO nha_xuat_ban SET Ten_nha_xuat_ban=N'".$post['Ten_nha_xuat_ban']."', Dia_chi=N'".$post['Dia_chi']."', Dien_thoai=N'".$post['Dien_thoai']."', Email=N'".$post['Email']."', Thong_tin_them=N'".$post['Thong_tin_them']."' ", dbconnect());  
		
	}
	
	function getid_auto_increment()
	{
		
		$r= mysql_query("SHOW TABLE STATUS LIKE 'Nha_xuat_ban'",dbconnect());
		$row = mysql_fetch_array($r); 
        $n = $row['Auto_increment']; 
        return $n;
		
		} 
	
	function getbyid_nxb($id)
	{
		$result= mysql_query("SELECT * FROM nha_xuat_ban WHERE ID=N'".$id."'",dbconnect());
		return mysql_fetch_array($result); 
	}
	
	
	function update_nxb($post)
	{
	$query= mysql_query("UPDATE nha_xuat_ban SET Ten_nha_xuat_ban=N'".$post['Ten_nha_xuat_ban']."', Dia_chi=N'".$post['Dia_chi']."', Dien_thoai=N'".$post['Dien_thoai']."', Email=N'".$post['Email']."', Thong_tin_them=N'".$post['Thong_tin_them']."'  WHERE ID=N'".$post['ID']."' ",dbconnect()); 	
	}
	
	function delete_nxb($id)
	{
		mysql_query("DELETE FROM Nha_xuat_ban WHERE ID=N'".$id."'",dbconnect());
	}
	
	function getbyall_nxb()
	{ 
		$allnxb_req = mysql_query("SELECT * FROM Nha_xuat_ban" ,dbconnect()); 
		$result = array(); 
		while ($nxb = mysql_fetch_array($allnxb_req))
		 { 
			$result[] = $nxb; 
		 } 
		return $result; 
	} 
	
	
	
?>
</body>
</html>